# -*- coding: UTF-8 -*-
"""
@File ：product_uom_category
@Author ：lucas
@Date ：2023-10-18 23:07:42
@Description: 
"""

import logging
from odoo import api, fields, models
from odoo.exceptions import UserError, ValidationError
from odoo.tools.float_utils import float_compare, float_round

_logger = logging.getLogger(__name__)


class UoMCategory(models.Model):
    _name = 'justdoo.uom.category'
    _description = '产品单位分类'

    name = fields.Char('名称', required=True)
    category_note = fields.Char(string='描述')
    uom_lines = fields.One2many('justdoo.product.uom', 'category_id', string='单位清单')
    company_name = fields.Char('公司', default=lambda self: self.env.company.name)
    company_id = fields.Integer('公司ID', default=lambda self: self.env.company.id)

    _sql_constraints = [('uniq_name', 'unique (name)', '名称已存在请不要重复添加!')]

    @api.model_create_multi
    def create(self, value_list):
        return super().create(value_list)
